/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var swapPairs = function(head) { 
    let cur = new ListNode();
    cur.next = head;
    let tmpHead = cur;
    while(cur.next!=null&&cur.next.next!=null) {
        let tmp1 = cur.next;
        let tmp2 = cur.next.next;
        tmp1.next = tmp2.next;
        tmp2.next = tmp1;
        cur.next = tmp2;

        cur = cur.next.next;
    }
    return tmpHead.next;
};